const chooseLocation = requirePlugin('chooseLocation');
Component({
    properties: {},
    data: {
        address: {},//选点后的位置地址信息
        location: {} // 定位信息
    },
    methods: {
        onLoad() {
            const that = this;
            wx.getLocation({
                success(res) {
                    console.log(res)
                    that.setData({
                        location: res
                    })
                }
            })
        },
        onShow() {
            const location = chooseLocation.getLocation(); // 如果点击确认选点按钮，则返回选点结果对象，否则返回null
            console.log("location==>",location);
            if(location !=null){
                this.setData({
                    address:location
                })
            }
        },
        chooseAddress() {
            const key = "YBEBZ-HABWB-SKHUH-JUPM5-DEBBV-IIFIG";
            const referer = "益智时间-map";
            const location = JSON.stringify({
                latitude: this.data.location.latitude, // 纬度
                longitude: this.data.location.longitude // 经度
            });
            // 自定义分类
            const category = '生活服务';
            wx.navigateTo({
                url: `plugin://chooseLocation/index?key=${key}&referer=${referer}&location=${location}&category=${category}`
            });
        }

    }
});
